import dayjs from 'dayjs';
import { Scale } from '../types/progress';

export function getFormatedToday(format = 'YYYY-MM-DD'): dayjs.Dayjs {
  return dayjs(dayjs().format('YYYY-MM-DD'))
}

export function getTodayScale(scales: Scale[]): Scale | null {
  const todayDate = getFormatedToday();
  return scales.find(item => item.date.isSame(todayDate)) ?? null;
}

export function parseLocStringToObject(str: string): { x: number, y: number, z: number } {
  const [x, y, z] = str.split(",").map(Number);
  return { x, y, z };
}
